import HTMLTestRunner_cn,logging,yagmail,pytest
import time
ttt=time.strftime('%Y%m%d-%H%M%S',time.localtime())
def log():
    tt=time.strftime('%Y%m%d-%H%M%S',time.localtime())
    logging.basicConfig(filename=tt+'163.log',filemode='w',level=logging.DEBUG,format='%(levelname)s %(filename)s %(asctime)s %(message)s %(lineno)d')

def baogao():
    baogao1=HTMLTestRunner_cn.HTMLTestRunner(open('./163.html','a+'),title='测试报告',description='163邮箱的测试报告')
    return baogao1

def emailll():
    ema=yagmail.SMTP(user='2314336117@qq.com',password='ixpbgkkezjwodhif',host='smtp.qq.com',port=465)
    ema.send(to='2314336117@qq.com',subject='163邮箱系统Web Ui自动化测试报告',contents=[f'{ttt}163.log',f'{ttt}163.html'])


if __name__ == '__main__':
    log()
    pytest.main([r"C:\Users\23143\PycharmProjects\pythonProject911\zyuekao\TesrCase.py",'-s',f'--html={ttt}163.html'])
    emailll()